package com.af.financeomine.web.action;

import java.util.logging.Logger;

import javax.servlet.http.HttpServletRequest;

import org.vraptor.annotations.Component;
import org.vraptor.annotations.In;
import org.vraptor.annotations.InterceptedBy;
import org.vraptor.annotations.Out;

import com.af.financeomine.web.interceptor.LoginInterceptor;
import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;

@Component
@InterceptedBy({LoginInterceptor.class})
public class HomeLogic {

	private static Logger log = Logger.getLogger(HomeLogic.class.getName());
	
	@In
    private HttpServletRequest request;
	private UserService userService;
	
	public HomeLogic(UserService userService) {
		this.userService = userService;
	}
	
	public void go(){
		log.info("redirected to home");
	}
	@Out
	public User getUser(){
		User user = userService.getCurrentUser();
		return user;
	}
	@Out
	public String getLoggoutUrl(){
		return userService.createLogoutURL(request.getRequestURI());
	}
}
